__wxCodeSpace__.batchAddCompiledTemplate(function (G, R, D, Q, gdc, X, Y, Z) {
  return {
    "pages/index/index": (() => {
      var P = "pages/index/index";
      var H = {};
      var I = {};
      H[""] = I[""] = (R, C, D, U) => {
        var L = R.c;
        var M = R.m;
        var O = R.r;
        var A = {
          markers: new Array(1),
          showPrivacyDiag: new Array(1),
          isSatelliteStyle: new Array(1),
          polyline: new Array(1),
          latitude: new Array(1),
          longitude: new Array(1),
          todayRunDistance: new Array(1),
        };
        var K = U === true;
        return {
          C: (C, T, E) => {
            E(
              "view",
              {},
              (N, C) => {
                if (C) R.y(N, "position: fixed;  width: 100%; height: 100%;");
              },
              (C, T, E) => {
                E(
                  "view",
                  {},
                  (N, C) => {
                    if (C) L(N, "content");
                  },
                  (C, T, E) => {
                    E(
                      "view",
                      {},
                      (N, C) => {
                        if (C) L(N, "map-wrap");
                      },
                      (C, T, E) => {
                        E(
                          "map",
                          {},
                          (N, C) => {
                            if (C) R.i(N, "map");
                            if (C || K || U.isSatelliteStyle)
                              O(N, "enable-satellite", D.isSatelliteStyle);
                            A["isSatelliteStyle"][0] = (D, E, T) => {
                              O(N, "enable-satellite", D.isSatelliteStyle);
                              E(N);
                            };
                            if (C || K || U.longitude)
                              O(N, "longitude", D.longitude);
                            A["longitude"][0] = (D, E, T) => {
                              O(N, "longitude", D.longitude);
                              E(N);
                            };
                            if (C) O(N, "show-location", "false");
                            if (C || K || U.latitude)
                              O(N, "latitude", D.latitude);
                            A["latitude"][0] = (D, E, T) => {
                              O(N, "latitude", D.latitude);
                              E(N);
                            };
                            if (C) O(N, "scale", "16");
                            if (C || K || U.markers) O(N, "markers", D.markers);
                            A["markers"][0] = (D, E, T) => {
                              O(N, "markers", D.markers);
                              E(N);
                            };
                            if (C || K || U.polyline)
                              O(N, "polyline", D.polyline);
                            A["polyline"][0] = (D, E, T) => {
                              O(N, "polyline", D.polyline);
                              E(N);
                            };
                          },
                          (C) => {}
                        );
                      }
                    );
                  }
                );
                E(
                  "view",
                  {},
                  (N, C) => {
                    if (C) L(N, "view-header");
                  },
                  (C, T, E) => {
                    E(
                      "view",
                      {},
                      (N, C) => {
                        if (C) L(N, "view-today-run");
                      },
                      (C, T, E) => {
                        E(
                          "view",
                          {},
                          (N, C) => {
                            if (C)
                              R.y(N, "margin-bottom: 30rpx; font-size: 50rpx;");
                          },
                          (C, T, E) => {
                            E(
                              "text",
                              {},
                              (N, C) => {},
                              (C, T) => {
                                C ? T("今日里程") : T();
                              }
                            );
                          }
                        );
                        E(
                          "view",
                          {},
                          (N, C) => {
                            if (C) L(N, "view-today-distance");
                          },
                          (C, T, E) => {
                            E(
                              "text",
                              {},
                              (N, C) => {
                                if (C)
                                  R.y(N, "font-size: 80rpx;font-weight: bold;");
                              },
                              (C, T) => {
                                C || K || U.todayRunDistance
                                  ? T(Y(D.todayRunDistance), (N) => {
                                      A["todayRunDistance"][0] = (D, E, T) => {
                                        T(N, Y(D.todayRunDistance));
                                      };
                                    })
                                  : T();
                              }
                            );
                            E(
                              "text",
                              {},
                              (N, C) => {
                                if (C)
                                  R.y(
                                    N,
                                    "margin-left: 20rpx; font-size: 30rpx;"
                                  );
                              },
                              (C, T) => {
                                C ? T("公里") : T();
                              }
                            );
                          }
                        );
                      }
                    );
                    E(
                      "view",
                      {},
                      (N, C) => {
                        if (C) L(N, "view-header-right");
                        if (C) R.y(N, "font-size: 30rpx;");
                      },
                      (C, T, E) => {
                        E(
                          "view",
                          {},
                          (N, C) => {
                            if (C) L(N, "view-record");
                            if (C) R.r(N, "bindtap", "onRecord");
                          },
                          (C, T, E) => {
                            E(
                              "image",
                              {},
                              (N, C) => {
                                if (C) O(N, "src", "../../images/history.png");
                              },
                              (C) => {}
                            );
                            E(
                              "text",
                              {},
                              (N, C) => {},
                              (C, T) => {
                                C ? T("历史记录") : T();
                              }
                            );
                          }
                        );
                        E(
                          "view",
                          {},
                          (N, C) => {
                            if (C) L(N, "view-rank");
                            if (C) R.r(N, "bindtap", "onRank");
                          },
                          (C, T, E) => {
                            E(
                              "image",
                              {},
                              (N, C) => {
                                if (C) O(N, "src", "../../images/rank.png");
                              },
                              (C) => {}
                            );
                            E(
                              "text",
                              {},
                              (N, C) => {},
                              (C, T) => {
                                C ? T("我的排名") : T();
                              }
                            );
                          }
                        );
                      }
                    );
                  }
                );
                E(
                  "view",
                  {},
                  (N, C) => {
                    if (C) L(N, "view-run-control");
                  },
                  (C, T, E) => {
                    E(
                      "view",
                      {},
                      (N, C) => {
                        if (C) L(N, "view-circle-out");
                      },
                      (C) => {}
                    );
                    E(
                      "view",
                      {},
                      (N, C) => {
                        if (C) R.r(N, "bindtap", "startRun");
                        if (C) L(N, "view-start");
                      },
                      (C, T, E) => {
                        E(
                          "image",
                          {},
                          (N, C) => {
                            if (C) O(N, "src", "../../images/start-run.png");
                            if (C) O(N, "mode", "aspectFit");
                          },
                          (C) => {}
                        );
                        E(
                          "text",
                          {},
                          (N, C) => {},
                          (C, T) => {
                            C ? T("开始") : T();
                          }
                        );
                      }
                    );
                  }
                );
                E(
                  "view",
                  {},
                  (N, C) => {
                    if (C) L(N, "view-map-btn");
                  },
                  (C, T, E) => {
                    E(
                      "view",
                      {},
                      (N, C) => {
                        if (C) L(N, "view-mapStyle");
                        if (C) R.r(N, "bindtap", "onChangeMapStyle");
                      },
                      (C, T, E) => {
                        E(
                          "image",
                          {},
                          (N, C) => {
                            if (C) O(N, "src", "../../images/style.png");
                          },
                          (C) => {}
                        );
                      }
                    );
                    E(
                      "view",
                      {},
                      (N, C) => {
                        if (C) L(N, "view-mapPosition");
                        if (C) R.r(N, "bindtap", "onLocate");
                      },
                      (C, T, E) => {
                        E(
                          "image",
                          {},
                          (N, C) => {
                            if (C) O(N, "src", "../../images/locate.png");
                          },
                          (C) => {}
                        );
                      }
                    );
                    E(
                      "view",
                      {},
                      (N, C) => {
                        if (C) L(N, "view-mapShare");
                      },
                      (C, T, E) => {
                        E(
                          "button",
                          {},
                          (N, C) => {
                            if (C) O(N, "open-type", "share");
                          },
                          (C, T, E) => {
                            E(
                              "image",
                              {},
                              (N, C) => {
                                if (C) O(N, "src", "../../images/share.png");
                              },
                              (C) => {}
                            );
                          }
                        );
                      }
                    );
                    E(
                      "view",
                      {},
                      (N, C) => {
                        if (C) L(N, "view-feedback");
                      },
                      (C, T, E) => {
                        E(
                          "image",
                          {},
                          (N, C) => {
                            if (C) O(N, "src", "../../images/feedback.png");
                          },
                          (C) => {}
                        );
                        E(
                          "button",
                          {},
                          (N, C) => {
                            if (C) O(N, "open-type", "contact");
                            if (C) R.y(N, "width: 100%;");
                            if (C) L(N, "view-contact-btn");
                          },
                          (C) => {}
                        );
                      }
                    );
                  }
                );
                E(
                  "view",
                  {},
                  (N, C) => {
                    if (C) L(N, "view-map-btn-left");
                  },
                  (C, T, E) => {
                    E(
                      "view",
                      {},
                      (N, C) => {
                        if (C) L(N, "view-ad");
                      },
                      (C, T, E) => {
                        E(
                          "ad-custom",
                          {},
                          (N, C) => {
                            if (C) O(N, "unit-id", "adunit-91c6eb46c253f614");
                          },
                          (C) => {}
                        );
                      }
                    );
                  }
                );
              }
            );
            E(
              "privacy-popup",
              {},
              (N, C) => {
                if (C) R.i(N, "myPrivacyPop");
                if (C || K || U.showPrivacyDiag)
                  O(N, "innerShow", D.showPrivacyDiag);
                A["showPrivacyDiag"][0] = (D, E, T) => {
                  O(N, "innerShow", D.showPrivacyDiag);
                  E(N);
                };
                if (C) R.v(N, "agree", "agree", !1, !1, !1, !1);
                if (C) R.v(N, "disagree", "disagree", !1, !1, !1, !1);
              },
              (C) => {}
            );
          },
          B: A,
        };
      };
      return function (P) {
        return H[P];
      };
    })(),
  };
});
__wxRoute = "pages/index/index";
__wxRouteBegin = true;
__wxAppCurrentFile__ = "pages/index/index.js";
define(
  "pages/index/index.js",
  function (
    require,
    module,
    exports,
    window,
    document,
    frames,
    self,
    location,
    navigator,
    localStorage,
    history,
    Caches,
    screen,
    alert,
    confirm,
    prompt,
    XMLHttpRequest,
    WebSocket,
    Reporter,
    webkit,
    WeixinJSCore
  ) {
    "use strict";
    var t,
      e = require("../../@babel/runtime/helpers/regeneratorRuntime"),
      a = require("../../@babel/runtime/helpers/asyncToGenerator"),
      o = getApp(),
      n = require("../../D38F48309100CF2FB5E920376AFB2D82.js"),
      i = !1;
    Page({
      data: {
        latitude: "39.872801",
        longitude: "116.413426",
        scale: 16,
        markers: [],
        polyline: [{ points: [], color: "#FB8337", width: 6, arrowLine: !0 }],
        todayRunDistance: 0,
        mapStyleKeys: [
          "RQIBZ-BJ56P-4L3DL-L2C6C-MLMHT-BNB2L",
          "6YMBZ-72KKI-PN2GY-5634L-XSBAK-OBFYA",
          "IW4BZ-TPJC6-P44SB-ED4PH-HE4SO-SZBOF",
        ],
        mapStyleKey: 0,
        mapStyleIndex: 1,
        mapStyleChoose: 1,
      },
      onLoad: function () {
        var t = this;
        (this.data.mapContext = wx.createMapContext("map")),
          this.setData({ isSatelliteStyle: o.globalData.enableSatelliteStyle }),
          wx.showLoading({ title: "初始化中", mask: !0 }),
          -1 != o.globalData.todayRunDistance
            ? (this.setData({
                todayRunDistance: o.globalData.todayRunDistance,
              }),
              (i = !0),
              this.checkHistoryData(),
              wx.hideLoading(),
              this.checkHasPrivacyAuthorize())
            : (o.getDatacallBack = function (e) {
                -1 != e &&
                  (t.setData({ todayRunDistance: e }),
                  (i = !0),
                  t.checkHistoryData()),
                  wx.hideLoading(),
                  t.checkHasPrivacyAuthorize();
              });
      },
      checkHistoryData:
        ((t = a(
          e().mark(function t() {
            var a;
            return e().wrap(
              function (t) {
                for (;;)
                  switch ((t.prev = t.next)) {
                    case 0:
                      return (
                        (a = this),
                        (t.next = 3),
                        wx.getStorage({
                          key: o.globalData.openId,
                          success: function (t) {
                            console.log(t);
                            var e = Date.parse(new Date());
                            if (
                              o.globalData.lastRunstartTime !=
                              t.data.record.runStartTime
                            )
                              if (
                                86400 <=
                                (e - t.data.record.runStartTime) / 1e3
                              ) {
                                var n = t.data.record,
                                  i = n.runPoints.length;
                                if (i > 1e3) {
                                  for (
                                    var c = Math.ceil(i / 1e3), s = [], l = 0;
                                    l < i;
                                    l += c
                                  )
                                    s.push(n.runPoints[l]);
                                  (n.runPoints = s), console.log(n);
                                }
                                a.uploadHistoryData(n);
                              } else
                                wx.showModal({
                                  title: "提示",
                                  content:
                                    "检测到您上次的跑步还没有结束，是否继续？",
                                  showCancel: !0,
                                  success: function (e) {
                                    e.confirm
                                      ? (wx.reLaunch({
                                          url:
                                            "../../pages/run/run?getInPage=index&exitType=" +
                                            t.data.exitType +
                                            "&records=" +
                                            JSON.stringify(t.data.record),
                                        }),
                                        wx.removeStorage({
                                          key: o.globalData.openId,
                                          success: function (t) {
                                            console.log(t);
                                          },
                                        }))
                                      : a.uploadHistoryData(t.data.record);
                                  },
                                });
                            else
                              wx.removeStorage({
                                key: o.globalData.openId,
                                success: function (t) {
                                  console.log(t);
                                },
                              });
                          },
                        })
                      );
                    case 3:
                    case "end":
                      return t.stop();
                  }
              },
              t,
              this
            );
          })
        )),
        function () {
          return t.apply(this, arguments);
        }),
      uploadHistoryData: function (t) {
        var e = {
            purpose: "updateRunRecord",
            key: { openId: o.globalData.openId, record: t },
          },
          a = this;
        n.request("", "POST", e)
          .then(function (e) {
            console.log(e),
              e &&
                e.data &&
                (a.setData({ todayRunDistance: e.data.todayRunDistance }),
                (o.globalData.todayRunDistance = a.data.todayRunDistance),
                (o.globalData.lastRunstartTime = t.runStartTime),
                wx.removeStorage({
                  key: o.globalData.openId,
                  success: function (t) {
                    console.log(t);
                  },
                }));
          })
          .catch(function (e) {
            console.log(e),
              wx.showToast({
                title: "网络异常",
                icon: "none",
                duration: 1e3,
                mask: !1,
              }),
              a.uploadHistoryData(t);
          });
      },
      checkAuthorize: function () {
        var t = this;
        wx.getSetting({
          success: function (e) {
            e.authSetting["scope.userLocationBackground"]
              ? t.getCurrentLocation()
              : wx.showModal({
                  title: "提示",
                  content:
                    '为确保手机息屏后也能获取到跑步轨迹，请先设置位置为"使用小程序时和离开后允许" 再进行跑步',
                  showCancel: !1,
                  success: function (t) {
                    t.confirm && wx.openSetting();
                  },
                });
          },
          fail: function (t) {
            console.log(t);
          },
        });
      },
      getCurrentLocation: function () {
        var t = this;
        wx.authorize({
          scope: "scope.userLocation",
          success: function (e) {
            console.log(e),
              wx.getLocation({
                type: "gcj02",
                isHighAccuracy: !0,
                success: function (e) {
                  console.log(e),
                    t.setData({ latitude: e.latitude, longitude: e.longitude }),
                    (o.globalData.latitude = e.latitude),
                    (o.globalData.longitude = e.longitude);
                },
                fail: function (t) {
                  console.log(t);
                },
              });
          },
          fail: function (t) {
            console.log(t);
          },
        });
      },
      startRun: function () {
        i
          ? this.checkHasPrivacyAuthorize() &&
            (this.checkGPS()
              ? wx.reLaunch({ url: "../../pages/run/run" })
              : wx.showModal({
                  title: "提示",
                  content: "为了保证定位精确，请先开启手机GPS定位哦",
                  showCancel: !1,
                }))
          : wx.showModal({
              title: "提示",
              content: "检测到网络异常，请点击右上角，选择重新进入小程序哦~",
              showCancel: !1,
            });
      },
      checkGPS: function () {
        return wx.getSystemInfoSync().locationEnabled;
      },
      onRecord: function () {
        wx.navigateTo({ url: "../../pages/record/record" });
      },
      onRank: function () {
        wx.navigateTo({ url: "../../pages/rank/rank" });
      },
      onLocate: function () {
        this.checkHasPrivacyAuthorize() &&
          (wx.showLoading({ title: "定位中", mask: !0 }),
          setTimeout(function () {
            wx.hideLoading();
          }, 1e3),
          this.getCurrentLocation());
      },
      onChangeMapStyle: function () {
        (this.data.isSatelliteStyle = !this.data.isSatelliteStyle),
          this.setData({ isSatelliteStyle: this.data.isSatelliteStyle }),
          (o.globalData.enableSatelliteStyle = this.data.isSatelliteStyle);
      },
      onReady: function () {},
      onShow: function () {
        o.globalData.hasPrivacyAuthrize && this.checkAuthorize();
      },
      onHide: function () {},
      onUnload: function () {},
      onPullDownRefresh: function () {},
      onReachBottom: function () {},
      onShareAppMessage: function () {
        return {
          title: "一起来跑步打卡吧~",
          path: "pages/index/index",
          imageUrl: "",
        };
      },
      checkHasPrivacyAuthorize: function () {
        return (
          !!o.globalData.hasPrivacyAuthrize ||
          (this.selectComponent("#myPrivacyPop").popUp(), !1)
        );
      },
      agree: function (t) {
        console.log("用户同意隐私授权, 接下来可以调用隐私协议中声明的隐私接口"),
          (o.globalData.hasPrivacyAuthrize = !0),
          this.checkAuthorize();
      },
      disagree: function (t) {
        (o.globalData.hasPrivacyAuthrize = !1),
          console.log("用户拒绝隐私授权, 未同意过的隐私协议中的接口将不能调用");
      },
    });
  },
  { isPage: true, isComponent: true, currentFile: "pages/index/index.js" }
);
require("pages/index/index.js");
